# -g 开启gdb的debug调试（生成的二进制文件中包含调试信息）
# -O0 禁用优化（确保调试一致性）
# -Wall 显示所有警告
CFLAGS := -g -O0 -Wall

log:=thirdparty/log/log.c thirdparty/log/log.h
log_test: test/log_test.c $(log)
	-gcc $(CFLAGS) $^ -o $@ -I thirdparty
#	-./$@
#	-rm $@

# $^: 依赖
# $@: 目标名
# -I：指定自定义的include path 查找目录

json:=thirdparty/cJSON/cJSON.c thirdparty/cJSON/cJSON.h
cJSON_test: test/json_test.c $(json) $(log)
	-gcc $^ -o $@ -I thirdparty
	-./$@
	-rm $@
app_common:=app/app_common.c app/app_common.h
common_test: test/common_test.c $(app_common) $(log)
	-gcc $^ -o $@ -I thirdparty -Iapp
	-./$@
	-rm $@

app_message:=app/app_message.h app/app_message.c
app_message_test: test/app_message_test.c $(app_message) $(app_common) $(log) $(json)
	-gcc $^ -o $@ -I thirdparty -Iapp
	-./$@
	-rm $@

mqtt_test: test/mqtt_test.c
	-$(CC) $^ -o $@ -lpaho-mqtt3c
	-./$@
	-rm $@

app_mqtt:=app/app_mqtt.h app/app_mqtt.c
app_mqtt_test: test/app_mqtt_test.c $(app_mqtt) $(log)
	-$(CC) $^ -o $@ -lpaho-mqtt3c -Iapp -Ithirdparty
	-./$@
	-rm $@

app_pool:=app/app_pool.h app/app_pool.c
app_poll_test: test/app_pool_test.c $(app_pool) $(log)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty
	-./$@
	-rm $@